<template>
    <el-dialog title=""  visible :show-close="false" :append-to-body="true"  class="wrap">
       <i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		 <div class="bt">学生休学</div>
        <el-form label-width="100px" class="form">
            <el-form-item label="学生名称">
                <el-input v-model="form.zwm" class="select-block"></el-input>
            </el-form-item>
            <el-form-item label="开始时间">
                <el-date-picker  v-model="form.kssj" :editable="false"  type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
       		 </el-form-item>
       		<el-form-item label="结束时间">
                <el-date-picker  v-model="form.jssj" :editable="false"  type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search">  </el-date-picker>
       		</el-form-item>
            <el-form-item label="休学原因">
 				<el-input v-model="form.note" type="textarea" :rows="4" placeholder="请输入休学原因" class="select-block"></el-input>
 			</el-form-item>
        </el-form>
        <el-button type="primary" class="submit" @click="submit">休学</el-button>
        <el-button type="danger" class="submit" @click="cancel">退出</el-button>
    </el-dialog>
</template>

<script type="text/javascript">
	import qs from 'qs'
    export default {
        props: ['params'],
        data () {
            return {
                form: {
                	zwm:'',
                	kssj:'',
                	jssj:'',
                	note:'',
                    id:''
                },
            }
        },
        created () {
        	console.log(this.params,'9999999999')
            this.form.zwm=this.params.row.zwm;
//           this.form.id=this.params.id;
              this.form.xsid=this.params.row.id;
        },
        methods: {
            submit () {
            if(this.form.kssj){
	          var time1 = this.$.getLocalTimeNo0(Date.parse(this.form.kssj));
	          var time2 = this.$.getLocalTimeNo0(Date.parse(this.form.jssj));
	        }else{
	          var time1 = this.form.kssj
	          var time2 = this.form.jssj
	        }
               
                if (!this.form.kssj) {
                    this.$message.warning('请选择开始时间');
                    return;
                }else if(!this.form.jssj){
                    this.$message.warning('请选择结束时间');
                    return;
                }else if(!this.form.note){
                    this.$message.warning('请填写休学原因');
                    return;
                }else if(this.form.jssj<this.form.kssj){
                    this.$message.warning('结束时间不能小于开始时间');
                    return;
                }
             this.$store.state.loading = true;
             var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                     xsid: this.params.row.id+'',
                        kssj: time1,
                        jssj: time2,
                        note: this.form.note+'',
                        xxid: logininfo.xxid+'',
                        yhid: logininfo.id+''
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xxjl/insert',  params2 )
                 .then(res => {
                    if (res.data.code == 1) {
                        this.$emit('close',{type:'xx',cancel:false});
                        this.$message.success(res.data.msg);
                        this.$store.state.loading = false;
                    }else{
                    	this.$message.warning(res.data.msg);
                        this.$store.state.loading = false;
                    }
                 }).catch(res => {
                 	this.$message.danger("服务器异常!");
                    this.$store.state.loading = false;
				})
            },
            cancel () {
                this.$emit('close',{type:'xx',cancel:true})
            },
        }
    }
</script>

<style lang="less" scoped>
    .wrap {
        text-align: center;
    }
   .bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
    .form {
        text-align: left;
        margin-top: 20px;

    }
    .input {
             display: inline-block;
         }
    .select-block {
        display: block;
        width: 85%;
    }
    .submit {
        width: 120px;
    }
</style>
